Communication device, control method of communication device, and program

ABSTRACT

A communication procedure for providing or receiving communication parameters can be performed by an easy operation even between devices having both a base station function and a slave station function. A communication device of the present invention determines a role of a device when performing a predetermined communication procedure for providing or receiving communication parameters, and selects operating as a base station or operating as a slave station based on the determined role. The communication device selects based on the determined role operating as a providing device or operating as a receiving device.

CROSS-REFERENCE TO RELATED APPLICATION

This application Continuation of U.S. application Ser. No. 14/311,900,filed Jun. 23, 2014; which is a Continuation of U.S. application Ser.No. 13/319,565, filed Nov. 9, 2011, now becomes U.S. Pat. No. 8,798,020,issued Aug. 5, 2014; which is a National Phase application ofInternational Application PCT/JP2010/002895, filed Apr. 22, 2010, whichclaims priority from Japanese Patent Application No. 2009-118973 filedMay 15, 2009, which is hereby incorporated by reference herein in itsentirety.

TECHNICAL FIELD

The present invention relates to a communication device, a controlmethod of the communication device, and a program.

BACKGROUND ART

In recent years, devices having functions both as an access point (AP)of infrastructure communication of wireless local area network (LAN)compliant with IEEE802.11 series, and as a station (STA) which connectsand communicates with the AP, have come on the market. Such a device canconstruct a network as an AP, and also can participate in a networkconstructed by other APs as an STA.

An example of communication device which can switch the role of thedevice (base device, slave device) is discussed in Japanese PatentApplication Laid-Open No. 2006-005844 and Japanese Patent ApplicationLaid-Open No. 2003-152730.

An example of communication device in which a function of a relaystation (access point) and a function of a station are operated at thesame time is discussed in U.S. Pat. No. 7,362,722 (Japanese PatentApplication Laid-Open No. 2005-086350).

When AP and STA communicate with each other, there are many settingitems which need to be set before use. For example, the setting itemsinclude communication parameters to perform wireless communication, suchas a service set identifier (SSID) as a network identifier, anencryption method, an encryption key, an authentication method, and anauthentication key. To set these communication parameters, automaticsetting methods for simply setting communication parameters to awireless communication device are devised by various manufacturers. Inthese automatic setting methods, communication parameters areautomatically set by providing communication parameters from one deviceto another device using a procedure and a message predetermined betweenthe devices to be connected to each other.

Non Patent Literature 1 discusses Wi-Fi protected setup (hereinafter,WPS), which is an industry standard of a communication parameterautomatic setting method between AP and STA.

When performing wireless communication between the devices having bothfunctions of the AP function and the STA function, the communication ispossible when one device constructs a network as an AP and the otherdevice connects to the network as an STA. When devices, which are in aninitial state and operate neither as AP nor as STA, try to communicatewith each other, the roles of the devices need to be determined, forexample, a device which becomes AP is determined.

In this case, when user's convenience is considered, it is desired thatthe determination of the roles is automatically performed between thedevices. However, a method in which the roles are automaticallydetermined between the devices without requiring user's operation hasnot been established. Therefore, when the devices have both the APfunction and the STA function, the automatic setting processing ofcommunication parameters cannot be performed, so that there is a problemthat the devices operating both as AP and as STA cannot easilycommunicate with each other.

CITATION LIST Non Patent Literature

-   [NPL 1]-   Wi-Fi CERTIFIED™ for Wi-Fi Protected Setup: Easing the User    Experience for Home and Small Office Wi-Fi® Networks,    http://www.wi-fi.org/wp/wifi-protected-setup

SUMMARY OF INVENTION

The present invention is directed to a communication method in which acommunication procedure for providing or receiving communicationparameters can be performed by an easy operation even between deviceshaving both a base station function and a slave station function.

According to an aspect of the present invention, a communication methoddetermines a role of a device when performing a predeterminedcommunication procedure for providing or receiving communicationparameters, selects operating as a base station or operating as a slavestation based on the determined role, selects based on the determinedrole operating as a providing device or operating as a receiving device.

Further features and aspects of the present invention will becomeapparent from the following detailed description of exemplaryembodiments with reference to the attached drawings.

BRIEF DESCRIPTION OF DRAWINGS

The accompanying drawings, which are incorporated in and constitute apart of the specification, illustrate exemplary embodiments, features,and aspects of the invention and, together with the description, serveto explain the principles of the invention.

FIG. 1A is a block diagram illustrating a configuration of a deviceaccording to an exemplary embodiment of the present invention.

FIG. 1B is a block diagram illustrating a configuration of a deviceaccording to an exemplary embodiment of the present invention.

FIG. 2A is a network configuration diagram of an exemplary embodiment ofthe present invention.

FIG. 2B is a network configuration diagram of an exemplary embodiment ofthe present invention.

FIG. 3 is a flowchart illustrating a communication processing of adevice A and a device B according to a first exemplary embodiment of thepresent invention.

FIG. 4A is a sequence diagram illustrating an operation of the device Aand the device B according to the first exemplary embodiment of thepresent invention.

FIG. 4B is a sequence diagram illustrating an operation of the device Aand the device B according to the first exemplary embodiment of thepresent invention.

FIG. 5 is a flowchart illustrating a communication processing of thedevice A and the device B according to a second exemplary embodiment ofthe present invention.

FIG. 6 is a sequence diagram illustrating an operation of the device Aand the device B according to the second exemplary embodiment of thepresent invention.

DESCRIPTION OF EMBODIMENTS

Various exemplary embodiments, features, and aspects of the inventionwill be described in detail below with reference to the drawings.

Hereinafter, although an example which uses a wireless LAN systemcompliant with IEEE802.11 series will be described, a communicationmethod is not limited to a wireless LAN compliant with IEEE802.11.

FIG. 1A is a hardware block diagram illustrating a configuration exampleof devices described below according to an exemplary embodiment to whichthe present invention can be applied. The device 101 is an entiredevice. A control section 102 controls the entire device by executing acontrol program stored in a storage section 103. The control section 102performs a communication parameter setting control between the deviceand another device. A storage section 103 stores the control programexecuted by the control section 102 and various information such as acommunication parameter. Various operations described below areperformed when the control section 102 executes the control programstored in the storage section 103. A wireless section 104 is forperforming wireless communication. A display section 105 displaysvarious information and has a function of outputting visible informationas a liquid crystal display (LCD) and a light-emitting diode (LED) and afunction of outputting audio information as a speaker.

A setting button 106 is a button to provide a trigger to startcommunication parameter setting processing. When the control section 102detects an operation of the setting button 106 by a user, the controlsection 102 performs processing described below. An antenna controlsection 107, and an antenna 108 are illustrated in FIG. 1A. An inputsection 109 is a section for a user to input various information.

FIG. 1B is a block diagram illustrating an example of a configuration ofsoftware function blocks performed by the devices in the communicationparameter setting processing described below. A device 201 is an entiredevice. A packet receiving section 202 is a section for receivingpackets of various communication. Beacon (notification signal) isreceived by the packet receiving section 202. Also, a device searchsignal such as a probe request is received by the packet receivingsection 202. The probe request can be treated as a network search signalfor searching a desired network. A probe response which is a responsesignal to the probe request is also received by the packet receivingsection 202.

A packet transmitting section 203 is a section for transmitting packetsof various communication. Transmission of beacon is performed by thepacket transmitting section 203. The probe request and the proberesponse which is a response signal to the probe request are alsotransmitted by the packet transmitting section 203. Various information(self-information) of a transmission source device is added to thedevice search signal and the response signal thereto. An AP controlsection is a section for controlling an access point (AP) communicationfunction. An operation as an access point (AP) described below isperformed by using the AP control section 204. The AP is a base station(base device, master station) which performs various controls ofwireless network. The AP is a device which establishes a network byitself when performing communication and performs various controls inresponse to a connection request from a station (STA). The AP transmitsa beacon periodically when performing communication, and when receivinga connection request signal transmitted from an STA, the AP transmits aconnection request response signal to the STA to connect with the STA.

An STA control section 205 is a section for controlling an STAcommunication function. An operation as a station (STA) described belowis performed by using the STA control section 205. The STA is a slavestation (slave device, mobile device) in a wireless network, andconnects to the AP when performing communication. When performingcommunication, the STA transmits a connection request signal to an AP,receives a connection request response signal from the AP to connectwith the AP, and performs communication under the control of the AP. Asdescribed in a second exemplary embodiment, wireless LAN ad-hoccommunication in which two STAs communicate with each other directly canbe performed by using the STA control section 205.

A network detection section 206 is a section for detecting a networkpresent in surrounding areas. A device can detect a network present insurrounding areas by receiving a beacon or a probe response from adevice in surrounding areas via the packet receiving section 202. It isalso possible to detect an AP, which is constructing a network, by usingthe network detection section 206. An AP detection operation describedbelow is performed by using the network detection section 206. Acommunication parameter providing section 207 is a section for providinga communication parameter to a device on the other side ofcommunication. Communication parameter automatic setting described belowis provided by the communication parameter providing section 207. Thecommunication parameter providing section 207 provides communicationparameters necessary for performing wireless communication, such as anSSID as a network identifier, an encryption method, an encryption key,an authentication method, and an authentication key. A communicationparameter receiving section 208 is a section for receiving acommunication parameter from the device on the other side ofcommunication. Communication parameter automatic setting described belowis received by the communication parameter receiving section 208.

A role determination section 209 is a section for determining a devicewhich manages network when performing communication between devices.Role determination processing described below is performed by the roledetermination section 209. By the role determination processing, eitherrole of “management device” or “terminal device” is provided to eachdevice. A device to which the role of management device is providedoperates as an AP by using the AP control section 204, and providescommunication parameters to the terminal by the parameter providingsection 207. On the other hand, a device to which the role of theterminal device is provided operates as an STA by using the STA controlsection 205, and receives communication parameters from the AP by theparameter receiving section 208.

A switching section 210 is a section for switching between operating asan AP using the AP control section 204, and operating as an STA usingthe STA control section 205, and selects the switched operation. Theswitching section 210 performs a first switching according to a roledetermined by the role determination section 209, a second switchingaccording to a detection result detected by the network detectionsection 206, and the like.

A selection section 211 is a section for selecting between operating asa providing device which provides a communication parameter using thecommunication parameter providing section 207, and operates as areceiving device using the communication parameter receiving section208. The selection section 211 performs a selection according to therole determined by the role determination section 209.

FIGS. 2A and 2B are diagrams illustrating network constructions of acommunication device-A 300 (hereinafter, device A) and a communicationdevice-B 301 (hereinafter, device B). These devices have configurationsillustrated in FIGS. 1A and 1B.

When the device A and the device B operate as an AP, the device A andthe device B respectively establish a network-A 302 (hereinafter,network A) and a network-B 303 (hereinafter, network B) (FIG. 2A). Afterthe device A and the device B detect each other, one of the devicesparticipates in a network established by the other device, and thedevices exchange messages for determining the management device. At thistime, all communication parameters are not set, but some communicationparameters by which the messages for determining the role can beexchanged are set. More specifically, a network identifier is stored ina signal (beacon, probe request, and probe response) used for devicedetection processing.

A device which tries to participate in the network sets a networkidentifier of the network in which the device tries to participate, andthereafter performs participation processing. The encryption method andthe encryption key have not been set yet. The device which becomes themanagement device as a result of the exchange of the messagesestablishes a network 401 as an AP, and provides communicationparameters to the STA by automatic setting of communication parameters(FIG. 2B).

The STA which has received the communication parameters participates inthe network by using the received communication parameters. Thecommunication parameter providing processing (receiving processing) isperformed by, for example, a communication parameter automatic settingprocedure such as Wi-Fi Protected Setup between devices. Thecommunication parameter automatic setting procedure is a communicationprocedure by which the providing device provides communicationparameters to the receiving device and the receiving device receives thecommunication parameters from the providing device. This procedure isperformed by exchanging predetermined messages between the devices.

FIG. 3 is a flowchart illustrating an example of an operation flow ofcommunication processing performed between the device A and the device Bwhen the setting button 106 is pressed. This operation is performed whenthe control section 102 reads the control program stored in the storagesection 103 and controls the wireless section 104 or the like.Hereinafter, a control performed by both devices will be described alongthe flowchart.

In the device in which the setting button 106 is pressed, the controlsection 102 starts the role determination section 209. In step S501, therole determination section 209 performs processing to search an accesspoint (AP) present in surrounding areas by using the network detectionsection 206. In step S502, the role determination section 209 checksinformation included in a received beacon or probe response, and checkswhether there is an AP which is performing the roll determinationprocessing.

In step S510, when there is at least one AP which is performing the rolldetermination processing, the role determination section 209 checkswhether there is one AP or more than one APs which are performing theroll determination processing. In step S512, when more than one APswhich are performing the roll determination processing are detected, anerror notification informing a user of an error is displayed on thedisplay section 105, and the role determination section 209 ends theprocessing due to an error.

In step S511, when there is one AP which is performing the rolldetermination processing, the role determination section 209 connects tothe network constructed by the detected AP using the STA control section205.

In step S503, when there is no AP which is performing the rolldetermination processing, the role determination section 209 starts anaccess point operation using the AP control section 204. When the APcontrol section 204 starts the access point operation, the AP controlsection 204 adds self-information indicating that the AP control sectionitself is performing the role determination processing, to a beacon anda probe response, and transmits the beacon and the probe response.

In step S504, the role determination section 209 exchanges arbitrationmessages with the device on the other side, and determines which devicebecomes the management device. As an example of the determinationprocessing in step S504, it is possible to use a method of includinginformation indicating a priority of the management device in thearbitration message and transmitting the arbitration message. In thiscase, by comparing the priority included in the arbitration messagereceived from the device on the other side and the priority of thedevice itself, a device having a higher priority is determined to be themanagement device. The priority of the management device is determinedbased on information such as a device type of the device, a remainingbattery level, manufacturer information, universally unique identifier(UUID), and media access control (MAC) address.

When the device itself is operating as an access point, a priorityhigher than a case where it is operating as a station, may be set. Also,the priority information may be set based on connectivity to othernetworks, such as whether the device itself can be connected to theInternet. Further, when the priority of the device on the other side andthe priority of the device itself are the same, by comparing informationunique to a device such as UUID and MAC address, a device whichsatisfies a predetermined condition may be determined to be themanagement device.

In step S505, after determining the role, the control section 102 checkswhether the determined role of the device itself is the managementdevice. In step S506, when the device itself is determined to be themanagement device, the control section 102 checks whether the deviceitself is operating as an AP. If operating as an AP, the processingproceeds to step S509. If not operating as an AP, the control section102 separates from the network connected by the STA control section 205in step S507. In step S508, after separating from the network, thecontrol section 102 starts an access point operation by using the APcontrol section 204. In step S509, thereafter, the control section 102starts processing to provide communication parameters to the receivingdevice using the communication parameter providing section 207. Thecommunication parameter providing processing is performed by performingthe communication parameter automatic setting procedure between theproviding device and the receiving device.

If the device itself is determined to be the terminal device as a resultof the role determination, the control section 102 checks whether thedevice itself is operating as an AP in step S513. If not operating as anAP, the processing proceeds to step S515. If operating as an AP, thecontrol section 102 stops the access point operation in step S514. Instep S515, after stopping the access point operation, the controlsection 102 operates as a receiving device using the communicationparameter receiving section 208, and starts processing to receive thecommunication parameters from the providing device.

In step S516, after starting the processing, the control section 102performs a search of an AP using the network detection section 206. As aresult of the search, if more than one APs which are performing thecommunication parameter providing processing are detected in step S517,the processing proceeds to step S512, displays an error notificationinforming a user of an error on the display section 105, and ends theprocess due to an error. If there is one AP which is performing thecommunication parameter providing processing in step S517, the controlsection 102 connects to the AP in step S518, and, as a receiving devicewhich receives the communication parameters from a providing device, thecontrol section 102 performs a predetermined communication parameterautomatic setting procedure with the AP.

FIGS. 4A and 4B are an example of a processing sequence in which thesetting button 106 is pressed in the device A and the device B, and thecommunication parameter automatic setting processing is performedbetween the device A and the device B.

FIG. 4A is an example illustrating a processing sequence in which thesetting button 106 is pressed in the device A and the device B, theroles are determined between the device A and the device B, and thedevice B becomes the management device to perform the communicationparameter automatic setting processing.

When the setting button 106 of the device B is pressed, the device Bperforms the processing of FIG. 3. The device B transmits a devicesearch signal (probe request), and checks whether there is an AP whichis performing the roll determination processing in areas around thedevice B (F601). In this case, since there is no AP which is performingthe roll determination processing in areas around the device B, thedevice B starts the access point operation to construct a network B(F602).

Thereafter, when the setting button 106 of the device A is pressed, thedevice A performs the processing of FIG. 3. The device A transmits adevice search signal, and checks whether there is an AP which isperforming the roll determination processing in areas around the deviceA (F603). The device search signal, which is an AP performing the rolldetermination processing, transmits a device search response signal(probe response) responding to the device search signal transmitted fromthe device A (F604). The device A receives the device search responsesignal from the device B, and recognizes that the device B is an APwhich is performing the roll determination processing by checking theadditional information in the signal. After recognizing that, the deviceA transmits a connection request signal to the device B, which is an APperforming the roll determination processing (F605).

The device B returns a connection request response signal indicatingconnection permission to the device A (F606). When the device A receivesthe connection request response signal from the device B, the device Aconnects to the device B and exchanges role arbitration messages todetermine the management device (F607, F608). Each device refers to theother device's priority information included in the role arbitrationmessage, and determines the management device by comparing the priorityinformation with priority information of its own. In this case, it isassumed that the device B becomes the management device.

After determining the role, the device B starts the communicationparameter providing processing (F609). On the other hand, the device Astarts the communication parameter receiving processing (F610). Sincethe device A has already connected to the device B, the device Atransmits a message indicating a start of the communication parametersetting to the device B (F613). Then, the communication parametersetting processing is performed by exchanging protocol messages for theautomatic setting procedure between the device A which is a receivingdevice and the device B which is a providing device (F614). As a result,communication parameters are transmitted from the device B to the deviceA, and the device B transmits a message indicating the completion of thecommunication parameter setting to the device A (F615).

In this way, the communication parameter setting processing iscompleted. The device A sets the communication parameters (a networkidentifier (SSID), an encryption method, an encryption key, anauthentication method, and an authentication key) received from thedevice B, and performs the communication connection processing again onthe device B (F616). The communication protocol processing of thecommunication parameter setting processing can be realized by usingcommunication protocol processing specified by industry standardcommunication parameter setting processing as discussed in Non PatentLiterature 1.

Next, a case in which a device operating as an STA during the roledetermination processing becomes the management device and providescommunication parameters will be described.

FIG. 4B is an example of a processing sequence in which the settingbutton 106 is pressed in the device A and the device B, the roles aredetermined between the device A and the device B, and the device Abecomes the management device to perform the communication parameterautomatic setting processing.

When the setting button 106 of the device B is pressed, the device Bperforms the processing of FIG. 3. The device B transmits the devicesearch signal, and checks whether there is an AP which is performing theroll determination processing in areas around the device B (F701). Inthis case, since there is no AP which is performing the rolldetermination processing in areas around the device B, the device Bstarts the access point operation to construct a network B (F702).

Thereafter, when the setting button 106 of the device A is pressed, thedevice A performs the processing of FIG. 3. The device A transmits adevice search signal (probe request), and checks whether there is an APwhich is performing the roll determination processing in areas aroundthe device A (F703). The device B, which is an AP performing the rolldetermination processing, transmits a device search response signal(probe response) responding to the device search signal transmitted fromthe device A (F704).

The device A receives the device search response signal from the deviceB, and recognizes that the device B is an AP which is performing theroll determination processing by checking the additional information inthe signal. After recognizing that, the device A connects to the deviceB (F705, F706), and exchanges role arbitration messages to determine themanagement device (F707, F708). Each device compares the other device'spriority information included in the role arbitration message with thepriority information of its own, and determines the management device.In this case, it is assumed that the device A becomes the managementdevice.

After determining the role, the device A starts the access pointoperation and constructs a network A (F709). After starting the accesspoint operation, the device A starts the communication parameterproviding processing (F710). On the other hand, the device B stops theaccess point operation (F711), and starts the communication parameterreceiving processing (F712). The device B transmits a connection requestsignal to the device A which is the management device and the AP (F713).The device A returns a connection request response signal indicatingconnection permission to the device B (F714).

When the device B receives the connection request response signal fromthe device A, the device B connects to the device A and transmits amessage indicating a start of the communication parameter setting(F715), and the communication parameter setting processing is performedbetween the device B which is the receiving device and the device Awhich is the providing device (F716). As a result, communicationparameters are transmitted from the device A to the device B, and thedevice A transmits a message indicating the completion of thecommunication parameter setting to the device B (F717). In this way, thecommunication parameter setting processing is completed. The device Bsets the communication parameters (i.e., a network identifier (SSID), anencryption method, an encryption key, an authentication method, and anauthentication key) received from the device A, and performs thecommunication connection processing again to the device A (F718).

As described above, even a device having both functions of a basestation and a slave station can determine a device that operates as abase station and a device that operates as a slave station. The devicecan also determine a device that operates as a communication parameterproviding device and a device that operates as a communication parameterreceiving device. Therefore, even when using a device having bothfunctions of a base station and a slave station, if a user performs anoperation such as pressing the setting button 106, the communicationparameter setting processing can be performed between devices. Further,by performing the communication parameter setting processing, settingshared communication parameters, and performing authenticationprocessing between devices, it is possible to perform encrypted wirelesscommunication.

As a second exemplary embodiment, a case in which the role determinationprocessing is performed by wireless LAN ad-hoc communication will bedescribed. The ad-hoc communication is wireless communication performeddirectly between stations without using an access point. The deviceconfiguration is the same as that in FIGS. 1A and 1B.

FIG. 5 is a flowchart illustrating an example of an operation flow ofcommunication processing performed between the device A and the device Bwhen the setting button 106 is pressed. This operation is performed whenthe control section 102 reads the control program stored in the storagesection 103 and controls the wireless section 104 or the like.Hereinafter, a control performed by both devices will be described alongthe flowchart.

In the device in which the setting button 106 is pressed, the controlsection 102 starts the role determination section 209. In step S801, thedevice constructs an ad-hoc network by using the STA control section205. When the STA control section 205 constructs the ad-hoc network, theSTA control section 205 adds self-information indicating that the STAcontrol section itself is performing the role determination processing,to a beacon and a probe response.

After constructing the ad-hoc network, in step S802, the roledetermination section 209 performs processing to search an ad-hocnetwork present in surrounding areas by using the network detectionsection 206. In step S803, the role determination section 209 checksinformation included in a received beacon or a probe response, andchecks whether there is an ad-hoc network which is performing the rolldetermination processing. In step S804, when there is at least onead-hoc network which is performing the roll determination processing,the role determination section 209 checks whether there is one ad-hocnetwork or more than one ad-hoc networks which are performing the rolldetermination processing.

In step S813, when there are more than one ad-hoc networks which areperforming the roll determination processing, an error notificationinforming a user of an error is displayed on the display section 105,and the processing ends due to an error. In step S805, when there is onead-hoc network which is performing the roll determination processing,the role determination section 209 participates in the ad-hoc network byusing the STA control section 205. When it participates in the network,the role determination section 209 stops the ad-hoc network constructedin step S801. After participating in the ad-hoc network, the roledetermination section 209 exchanges arbitration messages with the deviceon the other side in step S806, and determines which device becomes themanagement device in step S807.

In step S811, when there is no ad-hoc network which is performing theroll determination processing, the role determination section 209 waitsfor an role arbitration message transmitted from another device on thead-hoc network constructed by the role determination section 209 itself.In step S802, when the role determination section 209 does not receivean role arbitration message in step S811, the role determination section209 searches an ad-hoc network present in surrounding areas by using thenetwork detection section 206 again.

When receiving a role arbitration message in step S811, the roledetermination section 209 transmits a role arbitration message to thetransmission source device of the received role arbitration message instep S812, and determines which device becomes the management device instep S807. As an example of the determination processing, it is possibleto use a method of including priority information of the managementdevice in the arbitration message and transmitting the arbitrationmessage. In this case, by comparing the priority included in thearbitration message received from the device on the other side and thepriority of the device itself, a device having a higher priority isdetermined to be the management device.

The priority of the management device is determined based on informationsuch as a device type including a printer, a camera, and the like,service information included in the device itself, manufacturerinformation, UUID, and MAC address. The priority information may also beset based on a remaining battery level. Also, the priority informationmay be set based on connectivity to other networks, such as whether thedevice itself can be connected to the Internet. When the priority of thedevice on the other side and the priority of the device itself are thesame, the management device may be determined based on device uniqueinformation such as UUID and MAC address.

After determining the role, in step 808, the control section 102 checkswhether the determined role of itself is the management device. In stepS809, when the control section 102 determines itself to be themanagement device, the control section 102 starts an access pointoperation by using the AP control section 204. Thereafter, in step S810,the control section 102 starts processing to provide communicationparameters to the receiving device by using the communication parameterproviding section 207. When the receiving device is connected, as aproviding device, the control section 102 performs a predeterminedcommunication parameter automatic setting procedure with the receivingdevice, and performs the communication parameter providing processing.

After the check in step S808, when the control section 102 determinesitself to be the terminal device, the control section 102 startsprocessing to receive the communication parameters from the providingdevice using the communication parameter receiving section 208 in stepS814. Then, in step S815, the control section 102 searches an accesspoint by using the network detection section 206. As a result of thesearch, in step 816, when more than one APs which are performing thecommunication parameter providing processing are detected, theprocessing proceeds to step S813, displays an error notificationinforming a user of an error on the display section 105, and ends theprocess due to an error.

When there is one AP which is performing the communication parameterproviding processing in step S816, the control section 102 connects tothe AP in step S817, and, as a receiving device which receives thecommunication parameters from a providing device, the control section102 performs a predetermined communication parameter automatic settingprocedure together with the AP which is the providing device.

FIG. 6 is an example illustrating a processing sequence in which thesetting button 106 is pressed in the device A and the device B, theroles are determined between the device A and the device B, andthereafter the device A becomes the management device to perform thecommunication parameter automatic setting processing.

When the setting button 106 of the device B is pressed, the device Bperforms the processing of FIG. 5. The device B constructs an ad-hocnetwork B (F901), transmits a device search signal (probe request)(F902), searches a device which is performing the roll determinationprocessing in surrounding areas, and searches an ad-hoc network insurrounding areas.

When the setting button 106 of the device A is pressed, the device Aperforms the processing of FIG. 5. The device A constructs an ad-hocnetwork A (F903), transmits a device search signal (F904), searches adevice which is performing the roll determination processing insurrounding areas, and searches an ad-hoc network in surrounding areas.The device B transmits a device search response signal (probe response)responding to the device search signal transmitted from the device A(F905). The device A receives the device search response signal from thedevice B, and recognizes that the device B is performing the rolldetermination processing by checking the additional information in thesignal.

After recognizing that, the device A stops the network A andparticipates in the network B (F906), and then transmits a rolearbitration message to determine the management device, to the device B(F907). The device B, which receives the role arbitration message fromthe device A, transmits a role arbitration message to the device A(F908). Each device refers to the other device's priority informationincluded in the role arbitration message, and determines the managementdevice. In this case, it is assumed that the device A becomes themanagement device.

After determining the role, the device A starts the access pointoperation and constructs a network C (F909). After constructing thenetwork, the device A starts the communication parameter providingprocessing (F910). On the other hand, the device B stops the network B(F911), and starts the communication parameter receiving processing(F912). The device B searches a network in surrounding areas, searchesan AP which is performing the communication parameter providingprocessing, and detects the device A. The device B transmits aconnection request signal to the device A to request a connection(F913).

When the device A receives the connection request signal from the deviceB, the device A returns a connection request response signal indicatingconnection permission to the device B (F914). When receiving theresponse signal, the device B connects to the device A, transmits amessage indicating a start of the communication parameter setting to thedevice A (F915), and requests to start the communication parameterautomatic setting processing. Then, the communication parameter settingprocessing is performed between the device B which is the receivingdevice and the device A which is the providing device (F916). As aresult, communication parameters are transmitted from the device A tothe device B, and the device A transmits a message indicating thecompletion of the communication parameter setting to the device B(F917). In this way, the communication parameter setting processing iscompleted.

The device B sets the communication parameters (i.e., a networkidentifier (SSID), an encryption method, an encryption key, anauthentication method, and an authentication key) received from thedevice A, and performs the communication connection processing again onthe device A (F918).

As described above, even a device having both functions of a basestation and a slave station can determine a device that operates as aproviding device of communication parameters and a device that operatesas a receiving device of communication parameters. A device determinedto be the providing device can operate as the base station, and performthe communication parameter automatic setting processing. Therefore,even when using a device having both functions of a base station and aslave station, if a user performs an operation such as pressing thesetting button 106, the communication parameter setting processing canbe performed between devices. Further, by performing the communicationparameter setting processing, setting shared communication parameters,and performing authentication processing between devices, it is possibleto perform encrypted wireless communication.

The exemplary embodiments of the present invention have been describedabove. However, the exemplary embodiments are only examples fordescription of the present invention, and the scope of the presentinvention is not intended to be limited to the exemplary embodiments.The exemplary embodiments can be variously modified without departingfrom the scope of the present invention.

The above description is made using an example of wireless LAN compliantwith IEEE802.11. However, the present invention may be implemented inother wireless media such as wireless universal serial bus (USB), MBOA,Bluetooth (registered trademark), ultra wideband (UWB), and ZigBee.Also, the present invention may be implemented in wired communicationmedia such as wired LAN. Here, the MBOA is an abbreviation of Multi BandOFDM Alliance. The UWB includes wireless USB, wireless 1394, WINET, andthe like.

While the present invention has been described with reference toexemplary embodiments, it is to be understood that the invention is notlimited to the disclosed exemplary embodiments. The scope of thefollowing claims is to be accorded the broadest interpretation so as toencompass all modifications, equivalent structures, and functions.

What is claimed is:
 1. A communication device comprising: a base stationunit configured to operate as a base station which constructs a firstwireless network compliant with IEEE802.11 series; a station unitconfigured to operate as a station which is connected to a base stationthat constructs a second wireless network compliant with the IEEE802.11series; a providing unit configured to operate as a providing devicethat provides a first communication parameter for connecting to thefirst wireless network; a receiving unit configured to operate as areceiving device that receives a second communication parameter forconnecting to the second wireless network; a setting unit configured toset a value used for determining whether the communication deviceoperates as a first role or a second role, wherein, in a case where thecommunication device operates as the first role the communication deviceactivates the base station unit and the providing unit, and theproviding unit provides another communication device with the firstcommunication parameter, and wherein, in a case where the communicationdevice operates as the second role, the communication device activatesthe station unit and the receiving unit, and the receiving unitreceives, from the other communication device, the second communicationparameter; and a determination unit configured to perform adetermination process of determining whether the communication deviceoperates as the first role or the second role based on comparison of avalue set by the setting unit with a value received from the othercommunication device, wherein the setting unit is configured to set adifferent value based on whether the communication device activates thestation unit.
 2. The communication device according to claim 1, furthercomprising: a transmission unit configured to transmit the value set bythe setting unit.
 3. The communication device according to claim 2,further comprising: a search unit configured to search anothercommunication device, wherein the transmission unit is configured totransmit the value set by the setting unit to the other communicationdevice detected by the search unit.
 4. The communication deviceaccording to claim 3, comprising: a notification unit configured tonotify an error when more than one device capable of performing thedetermination process with the communication device is detected by thesearch unit.
 5. The communication device according to claim 1, wherein,in a case where the communication device constructs the first wirelessnetwork, the communication device transmits a beacon includinginformation about the first wireless network.
 6. The communicationdevice according to claim 1, wherein the first communication parameterincludes at least one of an encryption method, an encryption key, anauthentication method, and an authentication key.
 7. The communicationdevice according to claim 1, wherein the first communication parameterincludes a network identifier, an encryption method, an encryption key,an authentication method, and an authentication key.
 8. Thecommunication device according to claim 1, wherein the providing unitprovides the first communication parameter by wireless communication,and the receiving unit receives the second communication parameter bywireless communication.
 9. The communication device according to claim1, wherein the setting unit is configured to set a value to be set whenthe communication device does not activate the station unit larger thana value to be set when the communication device activates the stationunit.
 10. The communication device according to claim 1, wherein theproviding unit provides the first communication parameter by Wi-FiProtected Setup, and wherein the receiving unit receives a communicationparameter by Wi-Fi Protected Setup.
 11. The communication deviceaccording to claim 1, wherein a role of the communication device isdetermined to be the first role in a case where the value set by thesetting unit is higher than the value received from the othercommunication device, and a role of the communication device isdetermined to be the second role in a case where the value set using thesetting unit is lower than the value received from the othercommunication device.
 12. The communication device according to claim11, wherein the determination unit determines that the communicationdevice operates as the first role or the second role based oninformation different from the value set by the setting unit in a casewhere the value set by the setting unit and the value received from theother communication device are the same.
 13. A control method performedby a communication device comprising a base station unit configured tooperate as a base station which constructs a first wireless networkcompliant with IEEE802.11 series, a station unit configured to operateas a station which is connected to the base station that constructs asecond wireless network compliant with the IEEE802.11 series, aproviding unit configured to operate as a providing device that providesa first communication parameter for connecting to the first wirelessnetwork, and a receiving unit configured to operate as a receivingdevice that receives a second communication parameter for connecting tothe second wireless network, the control method comprising: setting avalue used for determining whether the communication device operates asa first role or a second role, wherein, in a case where thecommunication device operates as the first role, the communicationdevice activates the base station unit and the providing unit, and theproviding unit provides another communication device with the firstcommunication parameter, and wherein, in a case where the communicationdevice operates as the second role, the communication device activatesthe station unit and the receiving unit, and the receiving unitreceives, from the other communication device, the second communicationparameter; and performing a determination process of determining whetherthe communication device operates as the first role or the second rolebased on comparison of a value set by the setting unit with a valuereceived from the other communication device, wherein the setting sets adifferent value based on whether the communication device activates thestation unit.
 14. The control method according to claim 13, furthercomprising: transmitting the value set by the setting.
 15. The controlmethod according to claim 13, wherein the providing unit provides thefirst communication parameter by Wi-Fi Protected Setup, and wherein thereceiving unit receives a communication parameter by Wi-Fi ProtectedSetup.
 16. The control method according to claim 13, wherein the settingsets a value to be set when the communication device does not activatethe station unit larger than a value to be set when the communicationdevice activates the station unit.
 17. A non-transitorycomputer-readable storage medium storing a computer program for causinga computer to execute a control method performed by a communicationdevice comprising a base station unit configured to operate as a basestation which constructs a first wireless network compliant withIEEE802.11 series, a station unit configured to operate as a stationwhich is connected to the base station that constructs a second wirelessnetwork compliant with the IEEE802.11 series, a providing unitconfigured to operate as a providing device that provides a firstcommunication parameter for connecting to the first wireless network,and a receiving unit configured to operate as a receiving device thatreceives a second communication parameter for connecting to the secondwireless network, the control method comprising: setting a value usedfor determining whether the communication device operates as a firstrole or a second role, wherein, in a case where the communication deviceoperates as the first role, the communication device activates the basestation unit and the providing unit, and the providing unit providesanother communication device with the first communication parameter, andwherein, in a case where the communication device operates as the secondrole, the communication device activates the station unit and thereceiving unit, and the receiving unit receives, from the othercommunication device, the second communication parameter; and performinga determination process of determining whether the communication deviceoperates as the first role or the second role based on comparison of avalue set by the setting unit with a value received from the othercommunication device, wherein the setting sets a different value basedon whether the communication device activates the station unit.
 18. Thenon-transitory computer-readable storage medium according to claim 17,further comprising: transmitting the value set by the setting.
 19. Thenon-transitory computer-readable storage medium according to claim 17,wherein the providing unit provides the first communication parameter byWi-Fi Protected Setup, and wherein the receiving unit receives acommunication parameter by Wi-Fi Protected Setup.
 20. The non-transitorycomputer-readable storage medium according to claim 17, wherein thesetting sets a value to be set when the communication device does notactivate the station unit larger than a value to be set when thecommunication device activates the station unit.